package com.ep.modules.app.controller;

import com.ep.common.annotation.SysLog;
import com.ep.common.utils.PageUtils;
import com.ep.common.utils.R;
import com.ep.common.validator.ValidatorUtils;
import com.ep.modules.app.entity.AppDataSourceType;
import com.ep.modules.app.service.AppDataSourceTypeService;
import java.util.Map;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app/data_source_type")
public class AppDataSourceTypeController {
    @Autowired
    private AppDataSourceTypeService appDataSourceTypeService;

    @GetMapping("/list")
    public R list(Map<String, Object> params) {
        PageUtils page = appDataSourceTypeService.queryPage(params);
        return R.ok().put("page", page);
    }

    @GetMapping("/info/{id}")
    public R info(@PathVariable Long id) {
        AppDataSourceType appdatasourcetype = appDataSourceTypeService.getById(id);
        return R.ok().put("appdatasourcetype", appdatasourcetype);
    }

    @SysLog("保存AppDataSourceType")
    @PostMapping("/save")
    public R save(@RequestBody AppDataSourceType appdatasourcetype) {
        ValidatorUtils.validateEntity(appdatasourcetype);
        appDataSourceTypeService.save(appdatasourcetype);
        return R.ok();
    }

    @SysLog("修改AppDataSourceType")
    @PostMapping("/update")
    public R update(@RequestBody AppDataSourceType appdatasourcetype) {
        ValidatorUtils.validateEntity(appdatasourcetype);
        appDataSourceTypeService.update(appdatasourcetype);
        return R.ok();
    }

    @SysLog("删除AppDataSourceType")
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids) {
        appDataSourceTypeService.deleteBatch(ids);
        return R.ok();
    }
}